String[] list = new String[5];
The array object has five slots.
Once an array object has been constructed, the number of slots will not change. If an array object is to be used for the entire run of a program, its length must be large enough to accommodate all expected data. It is often hard to guess the correct length in advance. It would be nice if there were a kind of array where you could keep adding data no matter what length it was originally.
Say that an array has been declared and completely filled with information:
String[] list = new String[3]; list[0] = "ant" ; list[1] = "bat" ; list[2] = "cat" ;After running for a while, the program needs to add information to the array. Will the following statement make the array larger?
list = new String[5];